package com.nw.controller;

import com.nw.entity.User;
import com.nw.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    UserService userService;

    @RequestMapping("login")
    public HashMap<String ,Object> login(User user,String enCode) {
        HashMap<String, Object> map = userService.queryByUsername(user,enCode);
        return map;
    }

    @RequestMapping("add")
    public HashMap<String, Object> add(User user){
        System.out.println("前端发送的userAdd数据为:"+user);
        HashMap<String, Object> map = userService.add(user);
        return map;
    }

    @RequestMapping("getName")
    public HashMap<String, Object> userExist(String username){
        HashMap<String, Object> map = userService.userExist(username);
        return map;
    }
}
